﻿using System.Collections.Generic;
using System.Runtime.Serialization;
using GMME.Util;
using UnityEngine;
using UnityEngine.Scripting;

namespace GMME.Model.Rtm.Req
{
    [DataContract]
    internal class SubscribeRtmChannelReqForIos : SetPropertiesReq
    {
    }


    [DataContract]
    public class SubscribeRtmChannelReq
    {
        /**
         * 开发者传入的频道Id
         */
        [DataMember(Name = "channelId")]
        [Preserve]
        public string ChannelId { get; set; }

        /**
         * 频道内玩家属性
         */
        [DataMember(Name = "playerProperties")]
        [Preserve]
        public Dictionary<string, string> PlayerProperties { get; set; }

#if UNITY_ANDROID
        public static AndroidJavaObject ConvertSubscribeRtmChannelReq(SubscribeRtmChannelReq req)
        {
            var androidJavaObject =
                new AndroidJavaObject("com.huawei.game.gmme.model.rtm.SubscribeRtmChannelReq");
            androidJavaObject.Set("channelId", req.ChannelId);
            androidJavaObject.Set("playerProperties", TransferUtil.DictToMap(req.PlayerProperties));
            return androidJavaObject;
        }
#endif

        public string ConvertToJson()
        {
            var req = new SubscribeRtmChannelReqForIos();
            req.ChannelId = ChannelId;
            req.ConvertToPropertiesList(PlayerProperties);
            return JsonUtil.ToJson(req);
        }
    }
}